package screen.component
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	
	import helper.ValueObject;
	
	import screen.TechComBankScreen;

	public class Rule extends Popup
	{
		private const _RULE_NO:Number = 6;
		private const _RULE_UNIT_WIDTH:Number = 440;
		private const _TUTORIAL_AVATAR_FOLDER:String = "../assets/rule/";
		private var _tech_com_bank_screen:TechComBankScreen;
		private var _rule_group:MovieClip;
		public function Rule()
		{
			init();
		}
		private function init():void{
			_tech_com_bank_screen = TechComBankScreen.getInstance();
			_popup = ValueObject.T1_RESOURCE.getExportedAsset("rulePopup") as MovieClip;
			popupInit(_popup);
			_rule_group = new MovieClip;
			_popup.addChild(_rule_group);
			with(_popup){
				_rule_group.x = maskMc.x;
				_rule_group.y = maskMc.y;
				_rule_group.mask = maskMc;
				sliderInit(_rule_group,1,1,_rule_group.x,_RULE_UNIT_WIDTH);
				buttonImageInit(nextBtn);
				MovieClip(nextBtn).addEventListener(MouseEvent.CLICK,nextTutoHandle);
				buttonImageInit(preBtn);
				MovieClip(preBtn).addEventListener(MouseEvent.CLICK,preTutoHandle);
			}
			for(var i:Number=1;i<=_RULE_NO;i++){
				var rule_unit:MovieClip = ValueObject.T1_RESOURCE.getExportedAsset("tutorialUnit") as MovieClip;
				rule_unit.avatar.load(new URLRequest(_TUTORIAL_AVATAR_FOLDER + "rule" + i + ".png"));
				rule_unit.x = (i-1)*_RULE_UNIT_WIDTH;
				_rule_group.addChild(rule_unit);
			}
			updateSliderBtn(_rule_group);
		}
		private function nextTutoHandle(e:MouseEvent):void{
			sliderNextClick(_rule_group);
		}
		private function preTutoHandle(e:MouseEvent):void{
			sliderPreClick(_rule_group);
		}
	}
}